from PySide6.QtWidgets import *
from PySide6.QtCore import *
from PySide6.QtGui import *
from ui_main import *
import sys
import urllib.parse


#urllib.parse.quote

class Window(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        # 綁定事件
        self.pushButton.clicked.connect(self.encoding)
        self.pushButton_2.clicked.connect(self.decoding)
        
        self.show()
    
    def encoding(self):
        original = self.orinal.toPlainText()
        encoded = urllib.parse.quote(original,encoding=self.comboBox.currentText())
        self.encode.setPlainText(encoded)
        
    def decoding(self):
        encoded = self.orngial1.toPlainText()
        original = urllib.parse.unquote(encoded,encoding=self.comboBox_2.currentText())
        self.decode.setPlainText(original)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = Window()
    sys.exit(app.exec())